/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pkg.data;


import java.util.Date;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import java.util.Calendar;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import org.primefaces.event.SelectEvent;

/**
 *
 * @author Shengyi_Chen
 */
@ManagedBean
@RequestScoped
public class DateB {

    /**
     * Creates a new instance of DateB
     */
    private Date date;
    private String dateString;
    
    public DateB() {
        if (date == null){
            date = Calendar.getInstance().getTime();
            dateString = date.toString();
        }
    }
    
    public void handleDateSelect(SelectEvent event){
        Date dateSelected = (Date) event.getObject();
        setDateString(dateSelected.toString());        
    }
    /**
     * @return the date
     */
    public Date getDate() {
        return date;
    }

    /**
     * @param date the date to set
     */
    public void setDate(Date date) {
        this.date = date;
    }

    /**
     * @return the dateString
     */
    public String getDateString() {
        return dateString;
    }

    /**
     * @param dateString the dateString to set
     */
    private void setDateString(String dateString) {
        this.dateString = dateString;
    }
    
}
